var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("GridListView"),
    c = cc._decorator,
    l = c.ccclass,
    d = (c.property, c.requireComponent),
    u = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (t.contents = []), (t.root = null), t;
        }
        return (
            a(t, e),
            (t.prototype.init = function () {
                this.initParam(), this.initContent(), this.addItems();
            }),
            (t.prototype.setLayer = function (e, t) {
                (e.width = t.width), (e.height = t.height), (e.anchorX = t.anchorX), (e.anchorY = t.anchorY);
            }),
            (t.prototype.initContent = function () {
                var e = this.content;
                if (0 == this.contents.length) {
                    var t = this.getItem(),
                        o = t.childrenCount,
                        n = new cc.Node();
                    this.setLayer(n, e), (this.root = n), e.addChild(n);
                    for (var i = 0; i < o; i++) {
                        var a = new cc.Node();
                        this.setLayer(a, e), e.addChild(a), (this.contents[i] = a);
                    }
                    this.putItem(t);
                } else
                    for (n = this.root, this.setLayer(n, e), i = 0; i < this.contents.length; i++) {
                        var r = this.contents[i];
                        this.setLayer(r, e);
                    }
            }),
            (t.prototype.setItemPosition = function (e, t, o) {
                e.setPosition(t, o);
                var n = e.list;
                if (n)
                    for (var i = 0; i < n.length; i++) {
                        var a = n[i],
                            r = a.initPos;
                        r && ((a.x = t + r.x), (a.y = o + r.y));
                    }
            }),
            (t.prototype.setItemPositionX = function (e, t) {
                e.x = t;
                var o = e.list;
                if (o)
                    for (var n = 0; n < o.length; n++) {
                        var i = o[n],
                            a = i.initPos;
                        a && (i.x = t + a.x);
                    }
            }),
            (t.prototype.setItemPositionY = function (e, t) {
                e.y = t;
                var o = e.list;
                if (o)
                    for (var n = 0; n < o.length; n++) {
                        var i = o[n],
                            a = i.initPos;
                        a && (i.y = t + a.y);
                    }
            }),
            (t.prototype.setItemActive = function (e, t) {
                e.active = t;
                var o = e.list;
                if (o) for (var n = 0; n < o.length; n++) o[n].active = t;
            }),
            (t.prototype.addChild = function (e) {
                if (e.parent) this.setItemActive(e, !0);
                else {
                    var t = e.childrenCount;
                    if (((e.list = []), t > 0))
                        for (var o = 0, n = e.children; n.length > 0; ) {
                            var i = n[0];
                            if (!i) {
                                cc.warn(" element is null ", o);
                                break;
                            }
                            i.getComponent(cc.Widget) && i.removeComponent(cc.Widget),
                                (i.parent = this.contents[o]),
                                (i.initPos = cc.v2(i.x, i.y)),
                                e.list.push(i),
                                o++;
                        }
                    e.parent = this.root;
                }
            }),
            r([l, d(cc.ScrollView)], t)
        );
    })(s.default);
i.default = u;
